package com.itheima05;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;

public class UDP02 {
    public static void main(String[] args) throws IOException {

        DatagramSocket datagramSocket=new DatagramSocket(10000);

        while (true){

            byte[] bytes = new byte[1024];
            DatagramPacket datagramPacket=new DatagramPacket(bytes,bytes.length);
            datagramSocket.receive(datagramPacket);
            int length = datagramPacket.getLength();
            String s = new String(bytes, 0, length);
            System.out.println(s);
        }

    }
}
